/*********************
* Author:Dzlua
* QQ:505544956
* time:2016/11/11
*/
#ifndef __EDUI_SCROLLBAR_H__
#define __EDUI_SCROLLBAR_H__

#include "Slider.h"

EDUI_NAMESPACE_BEGIN

class EDUI_API ScrollBar : public Slider
{
public:
    struct {
        Event1<ScrollBar*> scroll;
        Event1<ScrollBar*> btn1Click;
        Event1<ScrollBar*> btn2Click;
    } evt;
protected:
    ScrollBar();
    virtual ~ScrollBar();
public:
	static ScrollBar* GetInterface();
	virtual void Release();
    static ScrollBar* ToScrollBar(Control* ctrl);
public:
    virtual Rect GetBarBkRect();
    virtual Rect GetButton1Rect();
    virtual Rect GetButton2Rect();
    bool SetButton1Size(const Size* sz);
    Size GetButton1Size() const;
    bool SetButton2Size(const Size* sz);
    Size GetButton2Size() const;
    bool  SetButton1Inset(const Rect1* inset);
    Rect1 GetButton1Inset() const;
    bool  SetButton2Inset(const Rect1* inset);
    Rect1 GetButton2Inset() const;
protected:
    virtual bool HandleMsg(Msg* msg);
    virtual void RenderStatusImages(IRender* render, const Rect* rc);
    virtual void SetAttribute(const char* name, const char* value);
    virtual ImageData* GetDestImageData(const char* dstname);
    virtual void DoEvent(EventType type, void* data1 = 0, void* data2 = 0);
protected:
    typedef void (ScrollBar::*ButtonClickFunc)();
    bool HandleMsgButton(Msg* msg, Rect& rc, ButtonState& state, ButtonClickFunc fun);
    void OnButton1Click();
    void OnButton2Click();
protected:
    Rect1 m_btn1Inset;
    Rect1 m_btn2Inset;
    Size m_btn1Size;
    Size m_btn2Size;

    ImageData m_btn1NoramlImage;
    ImageData m_btn1HotImage;
    ImageData m_btn1PressedImage;
    ImageData m_btn1DisabledImage;
    ImageData m_btn2NoramlImage;
    ImageData m_btn2HotImage;
    ImageData m_btn2PressedImage;
    ImageData m_btn2DisabledImage;
    
    ButtonState m_btn1State;
    ButtonState m_btn2State;

};

EDUI_NAMESPACE_END

#endif
